import scipy.stats as stats
import numpy as np

# 原假设H0=500，备选假设H1!=500
data = [512, 503, 498, 507, 496, 489, 499, 501, 496, 506]
u = 500
mean = np.mean(data)  # 样本均值
s = np.std(data, ddof=1)  # 样本标准差 无平方 ,自由度为n-1
# print(s)
n = 10  # 样本量
alpha = 0.01
t = (mean - u) / (s / np.sqrt(n))
t_score = stats.t.isf(alpha / 2, df=n - 1)
# print(np.abs(t), t_score)
if np.abs(t) <= t_score:
    print("拒绝假设")
else:
    print("接受假设")
